import router1 from "@/router";
import axios from "axios";

export default {
    isRedirect(code){
        if(code === 40100){
            console.log("40100")
            router1.push({
                name: "Userhome",
            }, () => {})
        }else if(code === 40101){
            console.log("40101")
            // 40101 : 未登录
            router1.push({
                name: "Login",
            }, () => {})
        }else if(code === 40102){
            console.log("40102")
            // 40102 : token 错误
            router1.push({
                name: "Login",
            }, () => {})
        }else if(code === 40103){
            console.log("40103")
            // 40103 : token 过期
                router1.push({
                name: "Login",
            }, () => {})
        }
    },
    addToken(){
        axios.defaults.headers.common['token'] = localStorage.getItem("token");
    },


}